package java.hilyb.dbtest;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

/**
 * User: wlai
 * Date: 12/23/2014
 * Time: 15:53 PM
 */
public class ServiceDemo extends Service {
    private static final String TAG = "LocalService";
    private IBinder binder=new ServiceDemo.LocalBinder();
    @Override
    public IBinder onBind(Intent intent) {

        return binder;
    }
    @Override
    public void onCreate() {
        Log.i(TAG, "onCreate");
        //这里可以启动媒体播放器
        // if(mediaPlayer==null)
        //     mediaPlayer=MediaPlayer.create(this, uri);
        super.onCreate();
    }

    @Override
    public void onStart(Intent intent, int startId) {
        Log.i(TAG, "onStart");
        super.onStart(intent, startId);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i(TAG, "onStartCommand");
        return START_STICKY;
    }



    @Override
    public void onDestroy() {
        Log.i(TAG, "onDestroy");
        super.onDestroy();
    }

    public class LocalBinder extends Binder{
        //返回本地服务
        ServiceDemo getService(){
            return ServiceDemo.this;
        }
    }

}
